﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Electrical;
using YArchitech.Revit;

namespace HYRElectric.PowerSystem
{
	internal class Common
	{
		public static void SetElementVisibility(Element ele, Document doc)
		{
            Category category = doc.Settings.Categories.get_Item((BuiltInCategory)ele.Category.Id.IntegerValue);
			if (!doc.ActiveView.GetYJKVisibility(category))
			{
				doc.ActiveView.SetYJKVisibility(category, true);
			}
		}

		public static ICollection<Element> GetAllPanel(Document doc, ElementId viewId)
		{
			return new FilteredElementCollector(doc, viewId).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_ElectricalEquipment).ToElements();
		}

		public static ICollection<Element> GetAllElectricalSystem(Document doc, ElementId viewId)
		{
			return new FilteredElementCollector(doc, viewId).OfClass(typeof(ElectricalSystem)).OfCategory(BuiltInCategory.OST_ElectricalCircuit).ToElements();
		}
	}
}
